package cn.wolfcode.wechat.service.impl;

import cn.wolfcode.wechat.domain.Coupon;
import cn.wolfcode.wechat.mapper.CouponMapper;
import cn.wolfcode.wechat.service.ICouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by A on 2017/12/30.
 */
@Service
public class CouponServiceImpl implements ICouponService{

    @Autowired
    private CouponMapper couponMapper;


    @Override
    public void saveCoupon(Long cilentId, Long couponId) {
        couponMapper.insertRelation(cilentId,couponId);
    }

    @Override
    public void deleteCoupon(Long cilentId, Long couponId) {
        couponMapper.DeleteRelation(cilentId,couponId);
    }

    @Override
    public List<Coupon> selectByCilentId(Long cilentId) {
        return couponMapper.selectByCilentId(cilentId);
    }

    @Override
    public Long selectCilentIdByOpenId(String openId) {
        return couponMapper.selectCilentIdByOpenId(openId);
    }

    @Override
    public Long selectCouponIdByPrizeNum(Long couponId) {
        return couponMapper.selectCouponIdByPrizeNum(couponId);
    }

    @Override
    public int selectRelation(Long cilentId, Long couponId) {
        return couponMapper.selectRelation(cilentId,couponId);
    }
}
